from configs import config_manage
from common.mysql_helper import MySqlServer
from common import logger
# import time
# import hmac
# import hashlib
# import base64
# import urllib.parse

# 日志
log = logger.Logger(name='qy_base_config')  # 公共调用，防止多次实例初始化


# 数据库实例化
DB_MERITPOINT_TEST = MySqlServer("MERITPOINT_TEST")
DB_ODMS_TEST = MySqlServer("ODMS_TEST")



# 配置文件实例化
loc = config_manage.get_yaml_page_loc(r'configs.yaml')

# 接口常用URL,BASE_HEADER
TEST_BASE_URL = loc['mpm3.0']['comunity_test']  # 常用api-test
PROD_BASE_URL = loc['mpm3.0']['comunity_prod']  # 常用api
TEST_FLOW_URL = loc['mpm3.0']['workflowx_test']  # 流程服务workflowx-test
TEST_PUSH_URL = loc['mpm3.0']['pushcenter_test']  #推送中心pushcenter-test
PROD_FLOW_URL = loc['mpm3.0']['workflowx_prod']  # 流程服务workflowx
PROD_PUSH_URL = loc['mpm3.0']['pushcenter_prod']  #推送中心pushcenter
TEST_AUTH_URL = loc['mpm3.0']['auth_test']  # 单点服务auth-test
PROD_AUTH_URL = loc['mpm3.0']['auth_prod']  # 单点服务auth
AUTH_TOKEN = loc['SSO_Authorization']
JSON_HEADER = {
        "Content-Type": "application/json",
        "Accept-Charset": "utf-8"
    }
FORM_DATA_HEADER = {
    "Content-Type": "application/x-www-form-urlencoded"
}


# 钉钉机器人url
# DINGDING_API = "https://oapi.dingtalk.com/robot/send?access_token=385528a189f063859b85c3bd7509b3ca668c7ae6b8ceccc0b0ae22522b4a80c9"
# def get_dingding_api():
#     timestamp = round(time.time() * 1000)  # 时间戳
#     secret = 'SECa0ab7f3ba9742c0b6c36d8808bf7b16e92706db52e1d09260193b6d466f149a8'  # 加签秘钥
#     secret_enc = secret.encode('utf-8')
#     string_to_sign = '{}\n{}'.format(timestamp, secret)
#     string_to_sign_enc = string_to_sign.encode('utf-8')
#     hmac_code = hmac.new(secret_enc, string_to_sign_enc, digestmod=hashlib.sha256).digest()
#     sign = urllib.parse.quote_plus(base64.b64encode(hmac_code))  # 最终签名
#     print(timestamp)
#     print(sign)
#
#     webhook_url = "https://oapi.dingtalk.com/robot/send?access_token=1554a3dd1e748cbf748e8e0ea9d3cb61c2ee008d32167313389ff14cccda34a2"  # 无加密的url
#
#     DINGDING_API = webhook_url + '&timestamp={}&sign={}'.format(timestamp, sign)  # 最终url，url+时间戳+签名
#     print(DINGDING_API)
#     return DINGDING_API

# 游乐宝/大客户-后台/收银台
# YLB_BG = "YLB-BackGround"
# YLB_CT = "YLB-CashTerminal"
# DKH_BG = "DKH-BackGround"
# DKH_CT = "DKH-CashTerminal"
# DKH_ZB = "DKH-ZB"


if __name__ == '__main__':
    # get_mac_address()
    # get_dingding_api()
    pass
